package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.dao.StudentDao;
import com.example.entity.Student;
import com.example.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentDao studentDao;


//    @Override
//    public List<Student> findAll() {
//        List<Student> students = studentDao.selectList(null);
//        return students;
//    }

    @Override
    public void selectName(String name) {
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        if (name!=null){
            queryWrapper.like(Student::getName,name);
        }

    }

    @Override
    public void add(Student student) {
        studentDao.insert(student);
    }

    @Override
    public Student findById(String id) {
        return studentDao.selectById(id);
    }

    @Override
    public void update(Student student) {
        studentDao.updateById(student);
    }

    @Override
    public void del(String id) {
        studentDao.deleteById(id);
    }

    @Override
    public List<Student> list(QueryWrapper<Student> wrapper) {
        return studentDao.selectList(wrapper);
    }

    @Override
    public List<Student> findAll(QueryWrapper<Student> wrapper) {
        return studentDao.selectList(wrapper);
    }

    @Override
    public Page<Student> findSll(Page<Student> page1, QueryWrapper<Student> queryWrapper) {
        return studentDao.selectPage(page1,queryWrapper);
    }
}
